package DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import MODEL.Ferramenta;

public class FerramentaDAO {
	public static void cadastrarFerramenta(Ferramenta ferramenta) throws SQLException{
		Connection conn = null;
		PreparedStatement stmt = null;
		Conexao com = new Conexao();
		
			try
			{
				conn = com.getConnection();
			} catch (InstantiationException e) {
				
				e.printStackTrace();
			} catch (Throwable e) {
				
				e.printStackTrace();
			}
			try{
		stmt=conn.prepareStatement("INSERT INTO ferramentas(nome_ferramenta,data_compraf,observacoes,disponibilidade) value(?,?,?,?)");
		stmt.setString(1,ferramenta.getNome_ferramenta());
		stmt.setString(2, ferramenta.getData_compraf());
		stmt.setString(3, ferramenta.getObservacoes());
		stmt.setString(4, ferramenta.getDisponibilidade());
		stmt.execute();
			}catch (SQLException e) {
				e.printStackTrace();
			}
			finally
			{
				if(conn != null)
					conn.close();
				if(stmt != null)
					stmt.close();
			}
		
	}
	

}
